import request from '@/utils/request'
import type { Dept, PageResult } from '@/types'

/**
 * 分页查询院系
 */
export function getDeptPage(params: any) {
  return request<PageResult<Dept>>({
    url: '/dept/page',
    method: 'get',
    params
  })
}

/**
 * 获取所有院系
 */
export function getDeptList() {
  return request<Dept[]>({
    url: '/dept/list',
    method: 'get'
  })
}

/**
 * 获取院系详情
 */
export function getDeptById(id: number) {
  return request<Dept>({
    url: `/dept/${id}`,
    method: 'get'
  })
}

/**
 * 新增院系
 */
export function addDept(data: Dept) {
  return request<void>({
    url: '/dept',
    method: 'post',
    data
  })
}

/**
 * 更新院系
 */
export function updateDept(data: Dept) {
  return request<void>({
    url: '/dept',
    method: 'put',
    data
  })
}

/**
 * 删除院系
 */
export function deleteDept(id: number) {
  return request<void>({
    url: `/dept/${id}`,
    method: 'delete'
  })
}

